// 定义翻译数据
const translations = {
    'zh-CN': {
        'title': '小米账号-登录',
        'header-left-p': '小米账号',
        'language': '中文（简体）',
        'denglu': '登录',
        'zhuce': '注册',
        'username-placeholder': '邮箱/手机号/小米ID',
        'password-placeholder': '密码',
        'accept-span': '我已阅读并同意小米账号用户协议和隐私政策',
        'login-btn': '登录',
        'wangjimima': '忘记密码',
        'shoujihao': '手机号登录',
        'qita': '其他方式登录',
        'footer-text': '小米公司版权所有-京ICP备10046444-京公网安备11010802020134号-京ICP证110507号'
    },
    'zh-TW': {
        'title': '小米帳號-登錄',
        'header-left-p': '小米帳號',
        'language': '中文（繁體）',
        'denglu': '登錄',
        'zhuce': '註冊',
        'username-placeholder': '電子郵件/手機號/小米ID',
        'password-placeholder': '密碼',
        'accept-span': '我已閱讀並同意小米帳號用戶協議和隱私政策',
        'login-btn': '登錄',
        'wangjimima': '忘記密碼',
        'shoujihao': '手機號登錄',
        'qita': '其他方式登錄',
        'footer-text': '小米公司版權所有-京ICP備10046444-京公網安備11010802020134號-京ICP證110507號'
    },
    'en-US': {
        'title': 'Xiaomi Account - Login',
        'header-left-p': 'Xiaomi Account',
        'language': 'English',
        'denglu': 'Login',
        'zhuce': 'Register',
        'username-placeholder': 'Email/Phone Number/Xiaomi ID',
        'password-placeholder': 'Password',
        'accept-span': 'I have read and agree',
        'login-btn': 'Login',
        'wangjimima': 'Forgot',
        'shoujihao': 'Phone Number',
        'qita': 'Other Methods',
        'footer-text': 'Copyright © Xiaomi Corporation - Record No.京ICP备10046444 - Record No.京公网安备11010802020134号 - Record No.京ICP证110507号'
    }
};

// 获取当前语言
let currentLanguage = 'zh-CN';

// 更新页面上的文本
function updateText(language) {
    currentLanguage = language;
    document.title = translations[language]['title'];
    document.querySelector('.header-left p').textContent = translations[language]['header-left-p'];
    document.querySelector('.language').textContent = translations[language]['language'];
    document.querySelector('.denglu a').textContent = translations[language]['denglu'];
    document.querySelector('.zhuce a').textContent = translations[language]['zhuce'];
    document.querySelector('#username').placeholder = translations[language]['username-placeholder'];
    document.querySelector('#password').placeholder = translations[language]['password-placeholder'];
    document.querySelector('.accept span').textContent = translations[language]['accept-span'];
    document.querySelector('.login-btn').textContent = translations[language]['login-btn'];
    document.querySelector('.wangjimima').textContent = translations[language]['wangjimima'];
    document.querySelector('.shoujihao').textContent = translations[language]['shoujihao'];
    document.querySelector('.qita').textContent = translations[language]['qita'];
    document.querySelector('.footer-text').textContent = translations[language]['footer-text'];
}

// 添加点击事件监听器
document.querySelectorAll('.language-list li').forEach(item => {
    item.addEventListener('click', function() {
        const language = this.textContent.trim();
        if (language === '中文(繁体)') {
            updateText('zh-TW');
        } else if (language === 'English') {
            updateText('en-US');
        } else if (language === '蒙古语') {
            updateText('mn-MN');
        } else if (language === '沙特阿拉伯') {
            updateText('ar-SA');
        }
    });
});